/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package afterubuntu;

import afterubuntu.log.Log;
import afterubuntu.view.AfterUbuntu;
import afterubuntu.view.AskPass;
import afterubuntu.view.GoogleCredentials;
import java.net.URISyntaxException;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author Kermit
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException ex) {
            Log.getInstance().log(Log.ERROR, ex.getLocalizedMessage());
        } catch (InstantiationException ex) {
            Log.getInstance().log(Log.ERROR, ex.getLocalizedMessage());
        } catch (IllegalAccessException ex) {
            Log.getInstance().log(Log.ERROR, ex.getLocalizedMessage());
        } catch (UnsupportedLookAndFeelException ex) {
            Log.getInstance().log(Log.ERROR, ex.getLocalizedMessage());
        }

        if(args.length > 0 && args[0].equalsIgnoreCase("askpass")){
            AskPass askPass = new AskPass();
            askPass.setLocationRelativeTo(null);
            askPass.setVisible(true);
        }else{
            AfterUbuntu afterUbuntu = new AfterUbuntu();
            afterUbuntu.setLocationRelativeTo(null);

            GoogleCredentials gCredentials = new GoogleCredentials(afterUbuntu, true);
            gCredentials.setLocationRelativeTo(null);
            gCredentials.loadPersistentData();

            afterUbuntu.setVisible(true);
            gCredentials.setVisible(true);
        }
    }

}
